package org.yjc.service;


import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.yjc.entity.KingRoot;
import org.yjc.entity.Lessee;
import org.yjc.repository.LesseeRepository;

@Service
public class LesseeService {
	@Autowired
	private LesseeRepository lesseeDAO;

	public List<Lessee> findAll() {
		return lesseeDAO.findAll();
	}

	public Page<Lessee> findAll(Specification spec, Pageable pageable) {
		return lesseeDAO.findAll(spec,pageable);
	}

	public void deleteById(Integer id) {
		lesseeDAO.deleteById(id);
	}

	public Lessee findById(Integer id) {
		Optional<Lessee> optional = lesseeDAO.findById(id);
		if(optional.isPresent()) {
			return optional.get();
		}
		return null;
	}

	public void save(Lessee lessee) {
		lesseeDAO.save(lessee);
	}

	public List<Lessee> findByLesseeadminId(Integer id) {
		return lesseeDAO.findByLesseeadminId(id);
	}
}
